package com.ruoyi.project.bajiaostar.jbhWepicture.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.jbhWepicture.domain.JbhWepicture;
import com.ruoyi.project.bajiaostar.jbhWepicture.service.IJbhWepictureService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 网站图片Controller
 * 
 * @author 写烧糊
 * @date 2024-07-18
 */
@Controller
@RequestMapping("/bajiaostar/jbhWepicture")
public class JbhWepictureController extends BaseController
{
    private String prefix = "bajiaostar/jbhWepicture";

    @Autowired
    private IJbhWepictureService jbhWepictureService;

    @RequiresPermissions("bajiaostar:jbhWepicture:view")
    @GetMapping()
    public String jbhWepicture()
    {
        return prefix + "/jbhWepicture";
    }

    /**
     * 查询网站图片列表
     */
    @RequiresPermissions("bajiaostar:jbhWepicture:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JbhWepicture jbhWepicture)
    {
        startPage();
        List<JbhWepicture> list = jbhWepictureService.selectJbhWepictureList(jbhWepicture);
        return getDataTable(list);
    }

    /**
     * 导出网站图片列表
     */
    @RequiresPermissions("bajiaostar:jbhWepicture:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JbhWepicture jbhWepicture)
    {
        List<JbhWepicture> list = jbhWepictureService.selectJbhWepictureList(jbhWepicture);
        ExcelUtil<JbhWepicture> util = new ExcelUtil<JbhWepicture>(JbhWepicture.class);
        return util.exportExcel(list, "jbhWepicture",null);
    }

    /**
     * 新增网站图片
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存网站图片
     */
    @RequiresPermissions("bajiaostar:jbhWepicture:add")
    @Log(title = "网站图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JbhWepicture jbhWepicture)
    {
        return toAjax(jbhWepictureService.insertJbhWepicture(jbhWepicture));
    }

    /**
     * 修改网站图片
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JbhWepicture jbhWepicture = jbhWepictureService.selectJbhWepictureById(id);
        mmap.put("jbhWepicture", jbhWepicture);
        return prefix + "/edit";
    }

    /**
     * 修改保存网站图片
     */
    @RequiresPermissions("bajiaostar:jbhWepicture:edit")
    @Log(title = "网站图片", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JbhWepicture jbhWepicture)
    {
        return toAjax(jbhWepictureService.updateJbhWepicture(jbhWepicture));
    }

    /**
     * 删除网站图片
     */
    @RequiresPermissions("bajiaostar:jbhWepicture:remove")
    @Log(title = "网站图片", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jbhWepictureService.deleteJbhWepictureByIds(ids));
    }
}
